CSharpTest.Net
SetList<T> Constructor(IEnumerable<T>)
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SetList<T> Class > SetList<T> Constructor : SetList<T> Constructor(IEnumerable<T>)

items

Glossary Item Box

Constructs a SetList

Syntax

Visual Basic (Declaration) 
Public Function New( _
   ByVal items As IEnumerable(Of T) _
)
C# 
public SetList<T>( 
   IEnumerable<T> items
)

Parameters

items

Example

Library/Library.Test/TestSetList.cs

C#Copy Code
SetList<string> list = new SetList<string>((IEnumerable<string>)new string[] { "a", "B" });
Assert.AreEqual("a,B", String.Join(",", list.ToArray())); 
            
list = new SetList<string>(2);
Assert.AreEqual("", String.Join(",", list.ToArray()));
list.Add("a");
list.Add("B");
Assert.AreEqual("a,B", String.Join(",", list.ToArray()));

list = new SetList<string>(2, StringComparer.Ordinal);
Assert.AreEqual("", String.Join(",", list.ToArray()));
list.Add("a");
list.Add("B");
Assert.AreEqual("B,a", String.Join(",", list.ToArray()));

list = new SetList<string>(2, StringComparer.OrdinalIgnoreCase);
list.Add("a");
list.Add("B");
Assert.AreEqual("a,B", String.Join(",", list.ToArray()));

list = new SetList<string>(new string[] { "B", "a" }, StringComparer.Ordinal);
Assert.AreEqual("B,a", String.Join(",", list.ToArray()));

list = new SetList<string>((IEnumerable<string>)new string[] { "B", "a" }, StringComparer.OrdinalIgnoreCase);
Assert.AreEqual("a,B", String.Join(",", list.ToArray()));
VB.NETCopy Code
Dim list As New SetList(Of String)(DirectCast(New String() {"a", "B"}, IEnumerable(Of String)))
Assert.AreEqual("a,B", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(2)
Assert.AreEqual("", [String].Join(",", list.ToArray()))
list.Add("a")
list.Add("B")
Assert.AreEqual("a,B", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(2, StringComparer.Ordinal)
Assert.AreEqual("", [String].Join(",", list.ToArray()))
list.Add("a")
list.Add("B")
Assert.AreEqual("B,a", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(2, StringComparer.OrdinalIgnoreCase)
list.Add("a")
list.Add("B")
Assert.AreEqual("a,B", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(New String() {"B", "a"}, StringComparer.Ordinal)
Assert.AreEqual("B,a", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(DirectCast(New String() {"B", "a"}, IEnumerable(Of String)), StringComparer.OrdinalIgnoreCase)
Assert.AreEqual("a,B", [String].Join(",", list.ToArray()))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys